<template>
  <div class>
    <el-form ref="form" :model="form" :inline="true" label-width="80px">
      <el-form-item label="所属公司" prop="companyName">
        <el-input v-model="form.companyName" placeholder="请输入公司名称"></el-input>
      </el-form-item>
      <el-form-item label="楼盘" prop="devName">
        <el-input v-model="form.devName" placeholder="请输入楼盘名称"></el-input>
      </el-form-item>
      <el-form-item label="审核状态">
        <el-select v-model="form.examineState" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="申请人">
        <el-input v-model="form.applyUser" placeholder="请输入申请人姓名"></el-input>
      </el-form-item>
      <el-form-item label="经纪人">
        <el-input v-model="form.brokerNameOrPhone" placeholder="请输入经纪人姓名或手机号"></el-input>
      </el-form-item>
      <el-form-item>
        <span class="demonstration">申请时间</span>
        <el-date-picker
          v-model="time"
          type="datetimerange"
          value-format="yyyy-MM-dd HH:mm:ss"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          align="left"
        ></el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 表格 -->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column fixed type="index" label="序号" width="50"></el-table-column>
      <el-table-column prop="code" label="批次号" width="150"></el-table-column>
      <el-table-column prop="city" label="城市" width="120"></el-table-column>
      <el-table-column prop="companyName" label="所属公司名称" width="120"></el-table-column>
      <el-table-column prop="companyName" label="奖励方式" width="120">
        <template slot-scope="scope">
          <div>{{scope.row.type === 1 ? "购物卡" : "现金"}}</div>
          <!-- <div v-if="scope.row.type === 1">
            购物卡
          </div>
          <div v-else>
            现金
          </div>-->
        </template>
      </el-table-column>
      <el-table-column prop="devName" label="楼盘" width="120"></el-table-column>
      <el-table-column prop="brokerName" label="经纪人" width="300"></el-table-column>
      <el-table-column prop="applyAmount" label="奖励金额（元）" width="120"></el-table-column>
      <el-table-column prop="shouldDeductTaxes" label="应扣税费（元）" width="120"></el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="form.pageNum"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="form.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      time: [],
      tableData: [],
      total: 0,
      form: {
        companyName: "",
        devName: "",
        examineState: "",
        applyUser: "",
        brokerNameOrPhone: "",
        beginTime: "",
        endTime: "",
        pageNum: 1,
        pageSize: 10
      },
      options: [
        {
          value: 1,
          label: "待审核"
        },
        {
          value: 2,
          label: "运营审核通过"
        },
        {
          value: 3,
          label: "财务审核通过"
        },
        {
          value: 4,
          label: "运营审核拒绝"
        },
        {
          value: 5,
          label: "财务审核拒绝"
        }
      ]
    };
  },
  beforeCreate() {},
  created() {
    this.list();
    // this.onSubmit();
  },
  mounted() {},
  beforeMount() {},
  methods: {
    list() {
      this.$axios
        .post("/commission/broker/apply/audit/list", this.form)
        .then(res => {
          this.tableData = res.rows;
          this.total = res.total;
        });
    },

    // 查看
    handleClick(row) {
      console.log(row);
     
      this.$router.push({
        path: "/brokerAwarddddd",
        query: {
          id: row.id
        }
      });
    },

    // 查询
    onSubmit() {
      this.form.pageNum = 1;
      this.form.beginTime = this.time[0];
      this.form.endTime = this.time[1];
      this.list();
    },
    // 重置
    resetForm() {
      this.form = {
        companyName: "",
        devName: "",
        examineState: "",
        applyUser: "",
        brokerNameOrPhone: "",
        beginTime: "",
        endTime: "",
        pageNum: 1,
        pageSize: 10
      };
      this.list();
    },

    // 分页
    handleSizeChange(val) {
      this.form.pageSize = val;
      this.list();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.form.pageNum = val;
      this.list();
    }
  }
};
</script>